package com.wkck.controller.admin;

import com.wkck.VO.PageResult;
import com.wkck.dto.LResumeBackendQueryConditionsDto;
import com.wkck.dto.LResumeBackendQueryFilesConditionsDto;
import com.wkck.result.Result;
import com.wkck.service.LResumeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @Author: CK
 * @Date: 2024/03/27/22:18
 * @Description:
 */
@Api(tags = "简历文件")
@Slf4j
@CrossOrigin
@RequestMapping("/fileResumeBg")
@RestController
public class ResumeFilesBgController {

    @Autowired
    private LResumeService resumeService;

    /***
     * @Author: CK
     * @Date: 2024/3/27
     * @Param: [dto]
     * @Description: 得到系统中所有简历
     */
    @PostMapping("/get-system-file-resumes")
    @ApiOperation(value = "得到系统中所有简历")
    public Result<PageResult> getAllUsersFileResume(@RequestBody LResumeBackendQueryFilesConditionsDto dto) {
        log.info("得到系统中所有简历 ====> {}", dto);
        return Result.success(resumeService.getAllUsersFileResume(dto));
    }

    /***
     * @Author: CK
     * @Date: 2024/3/28
     * @Param: [id]
     * @Description: 根据用户在线简历id下载简历
     */
    @GetMapping("/file/online/{id}")
    @ApiOperation(value = "根据在线简历id下载简历")
    public void downloadUserFileById(@PathVariable String id, HttpServletResponse response) {
        log.info("需要下载的简历id ===> {}" , id);
        resumeService.downloadUserFileById(id, response);
    }

    /***
    * @Author: CK
    * @Date: 2024/3/28
    * @Param: [map]
    * @Description: 删除简历文件ids
    */
    @DeleteMapping("/remove-files")
    @ApiOperation(value = "删除简历文件")
    public Result<Boolean> removeFilesByIds(@RequestBody Map<String, List<String>> map) {
        log.info("删除简历文件: {}", map.get("ids"));
        return Result.success(resumeService.removeFilesByIds(map.get("ids")));
    }
}
